package jjn.daily;

import java.util.Comparator;
import java.util.Optional;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * @author Jjn
 * @since 2023/7/25 15:04
 */
public class LeetCode2208 {
    public int halveArray(int[] nums) {
        PriorityQueue<Double> priorityQueue = new PriorityQueue<>(Comparator.reverseOrder());
        double total = 0;
        for (int num : nums) {
            total += num;
            priorityQueue.offer((double) num);
        }
        int count = 0;
        double current = 0;
        while (current < total / 2.0) {
            Double poll = Optional.ofNullable(priorityQueue.poll()).orElse(0.0);
            double v = poll / 2.0;
            current += v;
            count++;
            priorityQueue.offer(v);
        }
        return count;
    }
    
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        int[] nums = new int[count];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = scanner.nextInt();
        }
        System.out.println(new LeetCode2208().halveArray(nums));
    }
}
